package com.shopx.config.controller;

import com.shopx.base.anno.RepearSubmitChkAnno;
import com.shopx.base.anno.ShopxParamAnno;
import com.shopx.base.dto.Result;
import com.shopx.base.utils.ResultUtil;
import com.shopx.config.bean.SysCode;
import com.shopx.config.service.ISysCodeService;
import com.shopx.core.common.CommonConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;


/**
 * SysCode
 *
 * @author lituo 2021-01-04
 */
@RestController
@Slf4j
@RequestMapping(value = "/sysCode")
public class SysCodeController {

  @Autowired
  private ISysCodeService sysCodeService;

  @PostMapping("/testEx")
  @RepearSubmitChkAnno(lockTime = CommonConstant.REQ_TM)
  @ShopxParamAnno
  public Result<?> queryTest() {
    sysCodeService.testException();
    return ResultUtil.ok(true);
  }


  @PostMapping("/insert")
  @RepearSubmitChkAnno(lockTime = CommonConstant.REQ_TM)
  @ShopxParamAnno
  public Result<?> insert(@RequestBody @Valid SysCode sysCode) {
    sysCodeService.insert(sysCode);
    return ResultUtil.ok(true);
  }
}

